import java.util.StringTokenizer;

class P439_39643 {

	private static final int DIST_LENGTH = 64;
	
	private final static int[][] table = new int[DIST_LENGTH][DIST_LENGTH];
	
	private final static int LENGTH = 8;
	
	public static void main(String[] args) {
		
		for (int i = 0; i < DIST_LENGTH; i++) {
			for (int j = 0; j < DIST_LENGTH; j++) {
				if (i != j)
					table[i][j] = 9999;
			}
		}
		
		for (int i = 0; i < LENGTH; i++) {
			for (int j = 0; j < LENGTH; j++) {
				int source = getPosition(i, j);
				int x = j;
				int y = i;
				int destination;
				
				if ((x + 2 < LENGTH) && (y + 1 < LENGTH)) {
					destination = getPosition(y + 1, x + 2);
					table[source][destination] = 1;
					table[destination][source] = 1;
				}
				
				if ((x + 1 < LENGTH) && (y + 2 < LENGTH)) {
					destination = getPosition(y + 2, x + 1);
					table[source][destination] = 1;
					table[destination][source] = 1;
				}
				
				if ((x - 1 >= 0) && (y + 2 < LENGTH)) {
					destination = getPosition(y + 2, x - 1);
					table[source][destination] = 1;
					table[destination][source] = 1;
				}
				
				if ((x - 2 >= 0) && (y + 1 < LENGTH)) {
					destination = getPosition(y + 1, x - 2);
					table[source][destination] = 1;
					table[destination][source] = 1;
				}
				
				if ((x - 2 >= 0) && (y - 1 >= 0 )) {
					destination = getPosition(y - 1, x - 2);
					table[source][destination] = 1;
					table[destination][source] = 1;
				}
				
				if ((x - 1 >= 0) && (y - 2 >= 0)) {
					destination = getPosition(y - 2, x - 1);
					table[source][destination] = 1;
					table[destination][source] = 1;
				}
				
				if ((x + 1 < LENGTH) && (y - 2  >= 0)) {
					destination = getPosition(y - 2, x + 1);
					table[source][destination] = 1;
					table[destination][source] = 1;
				}
				
				if ((x + 2 < LENGTH) && (y - 1 >= 0)) {
					destination = getPosition(y - 1, x + 2);
					table[source][destination] = 1;
					table[destination][source] = 1;
				}
			}
		}
		
		for (int k = 0; k < DIST_LENGTH; k++) {
			for (int i = 0; i < DIST_LENGTH; i++) {
				for (int j = 0; j < DIST_LENGTH; j++) {
					if (table[i][j] > table[i][k] + table[k][j]) {
						table[i][j] = table[i][k] + table[k][j];
					}
				}
			}
		}
		
		String line = readLn();
		
		while (line != null) {
			StringTokenizer st = new StringTokenizer(line);
			String xx = st.nextToken();
			String yy = st.nextToken();
			
//			System.out.println("P439_39643.main() " + xx + ", " + yy);
//			System.out.println(getPosition(xx) + ", " + getPosition(yy));
			System.out.println("To get from " + xx + " to "+ yy + " takes "+ table[getPosition(xx)][getPosition(yy)] + " knight moves.");
			
			line = readLn();
		}
		
		
	}

	private static int getPosition(String index) {
		return (((int)index.charAt(1) - '1') * LENGTH )+ ((int)index.charAt(0) - 'a');
	}
	
	private static int getPosition(int i, int j) {
		return (i * LENGTH) + j;
	}
	
	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}

}